package pl.register.android.group;

import pl.register.android.program.Program;
import pl.register.android.student.Student;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Mateusz Strzelecki
 * @since 2013-04-14
 */
public class StudentsGroup {

    private Long id;

    private GroupType groupType;

    private Program program;

    private List<Student> students;

    public StudentsGroup(Long id, GroupType groupType) {
        this.id = id;
        this.groupType = groupType;
        this.students = new ArrayList<Student>();
        this.program = new Program();
    }

    public StudentsGroup(Long id, GroupType groupType, List<Student> students) {
        this.id = id;
        this.groupType = groupType;
        this.students = students;
        this.program = new Program();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public GroupType getType() {
        return groupType;
    }

    public Program getProgram() {
        return program;
    }

    public void setProgram(Program program) {
        this.program = program;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
        Collections.sort(students);
    }

    public void addStudent(Student student) {
        students.add(student);
        Collections.sort(students);
    }

    public void removeStudent(Student student) {
        students.remove(student);
    }

    @Override
    public String toString() {
        return "StudentsGroup{" +
                "id=" + id +
                ", groupType=" + groupType +
                ", students=" + students +
                '}';
    }
}